package com.jzoffer;

import java.util.*;

public class TheFirstAppearedChar {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str = scanner.nextLine();
        int res = FirstNotRepeatingChar(str);
        System.out.println(res);
        scanner.close();
    }

    public static int FirstNotRepeatingChar(String str){
        if(str == null || str.length() < 1){
            return -1;
        }
        List<Character> list = new ArrayList<>();
        char[] ch = str.toCharArray();
        int len = ch.length;
        for(int i = 0;i < len;i++) {
            char temp = ch[i];
            if (!list.contains(temp)) {
                list.add(Character.valueOf(temp));
            } else {
                list.remove(Character.valueOf(temp));
            }
        }
        if(list.size() <= 0) {
            return -1;
        }
        return str.indexOf(list.get(0));
    }

    /*
    *     public int FirstNotRepeatingChar(String str) {
        LinkedHashMap <Character, Integer> map = new LinkedHashMap<Character, Integer>();
        for(int i=0;i<str.length();i++){
            if(map.containsKey(str.charAt(i))){
                int time = map.get(str.charAt(i));
                map.put(str.charAt(i), ++time);
            }
            else {
                map.put(str.charAt(i), 1);
            }
        }
        int pos = -1;
        int i=0;
        for(;i<str.length();i++){
            char c = str.charAt(i);
            if (map.get(c) == 1) {
                return i;
            }
        }
        return pos;
    }
    * */


}
